//
//  UILabel+Attri.m
//  GC_OC
//
//  Created by Tianbao Wang on 2022/5/27.
//

#import "UILabel+Attri.h"

@implementation UILabel (Attri)

- (void)setAttribute:(NSString *)text diff:(NSString *)diiText diffColor:(UIColor *)diffColor diffFont:(UIFont *)diffFont {
    NSMutableAttributedString *attrText = [[NSMutableAttributedString alloc] initWithString:text];
    NSRange diffRange = [text rangeOfString:diiText];
    if (diffRange.location != NSNotFound) {
        [attrText addAttribute:NSForegroundColorAttributeName value:diffColor range:diffRange];
        [attrText addAttribute:NSFontAttributeName value:diffFont range:diffRange];

    }
    self.attributedText = attrText;
}

@end
